﻿<%@ Page Title="" Language="C#" MasterPageFile="~/Areas/Admin/Views/Shared/AdminMaster.Master" Inherits="System.Web.Mvc.ViewPage<dynamic>" %>

<asp:Content ID="Content1" ContentPlaceHolderID="MainContent" runat="server">
<script type="text/javascript">

    $('.btn').live('click', function () {
        var btn = $(this).attr('id');
        switch (btn) {
            case "btnTenDangNhap":
                onSuggestion(btn);
                break;
            case "btnHoTen":
                onSuggestion(btn);
                break;
            case "btnEmail":
                onSuggestion(btn);
                break;
            default:

        }
    });

    function onSuggestion(btn) {
        var search = "";
        switch (btn) {
            case "btnTenDangNhap":
                {
                    search = $('#tendangnhap').val();
                    $.get('<%= ResolveUrl("~/")%>Admin/GiaoVien/SearchResult', { s: search, type: "tendangnhap" },
                    function (data) {
                        $('#result').html(data);
                    });
                }
                break;
            case "btnHoTen":
                {
                    search = $('#hoten').val();
                    $.get('<%= ResolveUrl("~/")%>Admin/GiaoVien/SearchResult', { s: search, type: "hoten" },
                    function (data) {
                        $('#result').html(data);
                    });
                }
                break;
            case "btnEmail":
                {
                    search = $('#email').val();
                    $.get('<%= ResolveUrl("~/")%>Admin/GiaoVien/SearchResult', { s: search, type: "email" },
                    function (data) {
                        $('#result').html(data);
                    });
                }
                break;
            default:
                break;
        }
    }
</script>

    <legend>
        Tìm Kiếm Giáo Viên
    </legend>
    <div>
        <% using (Ajax.BeginForm("Search", "GiaoVien", new AjaxOptions
           {
               InsertionMode = InsertionMode.Replace,
               HttpMethod = "GET",
               UpdateTargetId = "result"
           }))
           //Tên Đăng Nhập, Họ Tên, Email...
           { %>

<div>
                    <label>Tên Đăng Nhập     :</label>
                    <input type="text" name="tendangnhap" id="tendangnhap" /> 
               </div>

                <div class="control-group">
                    <div class="controls">
                        <button id="btnTenDangNhap"  name="Search" type="button" class="btn btn-primary"><i class="icon-search"></i>Tìm Kiếm</button>
                    </div>
                </div>

                <div>
                    <label>Họ Tên      :</label>
                    <input type="text" name="hoten" id="hoten" />
                </div>

                <div class="control-group">
                    <div class="controls">
                        <button id="btnHoTen"  name="Search" type="button" class="btn btn-primary"><i class="icon-search"></i>Tìm Kiếm</button>
                    </div>
                </div>

               <div>
                    <label>Email    :</label>
                    <input type="text" name="email" id="email" />
               </div>

                <div class="control-group">
                    <div class="controls">
                        <button id="btnEmail"  name="Search" type="button" class="btn btn-primary"><i class="icon-search"></i>Tìm Kiếm</button>
                    </div>
                </div> 

        <% } %>
    <div id="result"></div>
    <div>
        <a href="<%=ResolveUrl("~/Admin/GiaoVien/Index") %>">
        <button class="btn btn-primary">
        <i class="icon-reply"></i>
            Quay lại danh sách
        </button></a>
    </div>


    </div>
</asp:Content>

<asp:Content ID="Content2" ContentPlaceHolderID="head" runat="server">
</asp:Content>
